package com.thrd.taiexhibition.model;

import com.alibaba.fastjson.JSON;
import com.thrd.basicframework.http.OkHttpUtils;
import com.thrd.basicframework.http.callback.ThrdCallBack;
import com.thrd.taiexhibition.bean.BeanRichText;
import com.thrd.taiexhibition.callback.MvpCallback;
import com.thrd.taiexhibition.utils.Constant;

/**
 * @author: ${唐杰}
 * @date: 2021/4/6
 */
public class RichTextModel {

    public static final String TAG="RichTextModel";


    /**
     * 获取城市首页
     */
    public void getRichTextData(final MvpCallback<BeanRichText> mvpCallback, String articleId) {
        OkHttpUtils.get().url(Constant.HTTP_RICH_TEXT)
                .tag(TAG)
                .addParams("articleId",articleId)
                .build().execute(new ThrdCallBack<BeanRichText>() {
            @Override
            public void onFailed(String e, int code) {
                mvpCallback.onFailed(e, code);
            }

            @Override
            public void onResponse(BeanRichText response, int id) {
                mvpCallback.onSuccess(response);
            }

            @Override
            public BeanRichText onJson(String s) {
                return JSON.parseObject(s, BeanRichText.class);
            }
        });
    }
}
